package leetcode.ge100;

import leetcode.lt100.TreeNode;

class Solution_235 {

	public TreeNode lowestCommonAncestor(TreeNode root, TreeNode p, TreeNode q) {
		int val = root.val;
		if (val > p.val && val < q.val)
			return root;
		if (val > p.val && val > q.val)
			return lowestCommonAncestor(root.left, p, q);
		if (val < p.val && val < q.val)
			return lowestCommonAncestor(root.right, p, q);
		return root;
	}

}
